package com.shiguiwu.springmybatis.spring.lifecycle.merge;

import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;

/**
 * @description: 4，合并阶段
 * @author: stone
 * @date: Created by 2021/3/23 23:06
 * @version: 1.0.0
 * @pakeage: com.shiguiwu.springmybatis.spring.lifecycle.merge
 */
public class MergeTests {

    public static void main(String[] args) {

        DefaultListableBeanFactory factory = new DefaultListableBeanFactory();

        XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(factory);

        reader.loadBeanDefinitions("spring/merge.xml");

        String[] definitionNames = factory.getBeanDefinitionNames();
        for (String definitionName : definitionNames) {
            System.out.println(definitionName);
            System.out.println("========================================");

            BeanDefinition beanDefinition = factory.getBeanDefinition(definitionName);
            BeanDefinition mergedBeanDefinition = factory.getMergedBeanDefinition(definitionName);

            System.out.println("解析xml过程中的bean definitionName:" + beanDefinition);
            System.out.println("解析xml过程中的bean definitionName 的属性信息:" + beanDefinition.getPropertyValues());
            System.out.println("==========================================");

            System.out.println("解析xml过程中的合并bean definitionName:" + mergedBeanDefinition);
            System.out.println("解析xml过程中的合并bean definitionName 的属性信息:" + mergedBeanDefinition.getPropertyValues());

            System.out.println("-------------------------------------------");
        }
    }


}
